package cc.vv.btpartyjob.partyservice.delegate

import android.annotation.SuppressLint
import android.widget.ImageView
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.baselibrary.view.LKCircleImageView
import cc.vv.btpartyjob.jnimodule.server.OperationServer
import cc.vv.btpartyjob.partyservice.R
import cc.vv.lkimagecomponent2.LKImage
import cc.vv.lkimagecomponent2.lib.mode.ScaleMode
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 志愿者详情托管类
 * Created by Chen.qi on 2018/10/24.
 */
@SuppressLint("SetTextI18n")
class VolunteerPersonDetailActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_voluteer_person_detail
    }


    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_avpD_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_avpD_topBar)
        titleBar?.setEventInterface(event)
    }

    fun setImageBg() {
        val viewBg = getView<ImageView>(R.id.iv_avpD_voBg)
        LKImage.load().scale(ScaleMode.CENTER_CROP).loadAsserts("icon_volunteer_bg_pic.png")
                .into(viewBg)

    }

    /**
     *设置志愿者头像
     */
    fun setVolunteerHead(headPath: String?) {
        val volunteerView = getView<LKCircleImageView>(R.id.liv_avpD_userAvatar)
        LKImage.load().load(headPath).placeHolder(R.mipmap.icon_def_image).error(R.mipmap.icon_def_image)
                .scale(ScaleMode.CENTER_CROP).into(volunteerView)
    }

    /**
     *设置志愿者名称
     */
    fun setVolunteerName(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_name)
        volunteerView?.text = voStr
    }

    /**
     * 设置性别图标
     */
    fun setSexIcon(sex: Int?) {
        val volunteerView = getView<ImageView>(R.id.iv_avpD_sex)
        val tvSex = getView<TextView>(R.id.tv_avpD_sex)
        if (0 == sex) {
            volunteerView?.setImageResource(R.mipmap.icon_party_man)
            tvSex?.text = "男"
        } else {
            volunteerView?.setImageResource(R.mipmap.icon_party_woman)
            tvSex?.text = "女"
        }
    }


    /**
     *设置志愿类型
     */
    fun setVolunteerType(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_volunteerType)
        volunteerView?.text = "志愿类型: $voStr"
    }

    /**
     * 设置年龄
     */
    fun setVolunteerAge(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_age)
        volunteerView?.text = voStr
    }

    /**
     * 设置职业
     */
    fun setVolunteerZhiYe(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_zhiYe)
        volunteerView?.text = voStr
    }

    /**
     * 设置特长
     */
    fun setVolunteerTechang(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_teChang)
        volunteerView?.text = voStr
    }

    /**
     * 设置联系方式
     */
    fun setVolunteerPhone(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_phone)
        volunteerView?.text = voStr
    }


    /**
     * 设置地区
     */
    fun setVolunteerDiQu(street: String?, shequ: String?, grid: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_suoShuDiQu)
        volunteerView?.text = "$street $shequ $grid"
    }

    /**
     * 设置职业时间
     */
    fun setVolunteerZyTime(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_volunteerTime)
        volunteerView?.text = OperationServer.formatStr(voStr)
    }

    /**
     * 设置备注
     */
    fun setVolunteerRemark(voStr: String?) {
        val volunteerView = getView<TextView>(R.id.tv_avpD_remark)
        volunteerView?.text = voStr
    }


}